package ar.edu.itba.bundundu;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.code.facebookapi.FacebookParam;

public class InviteServlet extends HttpServlet{
  private static final long serialVersionUID = 1L;

  @Override
  protected void doPost(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {
   
	  RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/invite.jsp");
	  
    try{
      Facebook facebook= new Facebook(req.getParameter(FacebookParam.SESSION_KEY.toString()));
      String uids=facebook.getUidsFriends();
      Long loggedInUser = facebook.getClient().users_getLoggedInUser();
      String addUrl = facebook.getAddUrl();
      
      req.setAttribute("uids", uids);
      req.setAttribute("loggedInUser", loggedInUser);
      req.setAttribute("addUrl", addUrl);
      
      
    }catch(Exception e){
      //e.printStackTrace();
    }
    
    dispatcher.forward(req, resp);
   
  }
  
}
